package com.seafwg.interceptor;


import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @Author seafwg
 * @Date 2022/3/8 9:09 上午
 * @Version 1.0
 * @description xxx
 */

public class MyHandlerInterceptor implements HandlerInterceptor {
    // controller层接口方法执行之前，返回true，放行
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("preHandle exe...");
        return true;
    }

    // 目标方法执行之后，视图内容返回之前执行
    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println("postHandle exe...");
    }

    // 流程执行完之后执行
    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("afterCompletion exe...");
    }
}
